{% extends "base_generic.html" %}
{% block script %}
<script type="text/javascript">
function generateUrl(name) {
  var sanitizedName = string_to_slug(name);
  $("#url").val(sanitizedName);
}

$(window).load(
    function() {
      arraymuestra = new Array();
      arraymuestra['imagetype']='muestra';
      arraymuestra['service']='uploaded';
      imageUploader('imgmuestra', 'linkcategory', '{{filekey}}', 'Muestra',arraymuestra);
    });

function deleteImage(key,id){
   $.post('/admin/image/delete/' + key + '/',
    function(data){
      data = eval(data);
      $('#' + data[0].type).remove();
    });
}

function Muestra(key){
  strhtml="<div class=\"imgremovable\" id=\"muestra\"><span class=\"info\">Muestra <a class=\"ax\" href=\"#\" onclick=\"deleteImage('" + key + "');return false;\">del</a></span><img src=\"/image/"+key+"/80/80/cropped/\" /></div>";
  $('#images').append(strhtml);
}
</script>
{% endblock %}
{% block content %}
	<h1>Category Link</h1>
<form name="edit-admin" id="edit-admin" method="post" action="{{path}}">
<div class="field">
<label for="originalname">Name:</label>
<input type="text" name="name" id="name" value="{{linkcategory.name}}" onblur="generateUrl($('#name').val())" />
</div>
<div class="field">
<label for="url">URL:</label>
<input type="text" name="url" id="url" value="{{linkcategory.url}}" />
</div>
<div class="field">
<label for="order">Order:</label>
<input type="text" name="order" id="order" value="{{linkcategory.order|default_if_none:"0"}}" />
</div>
<div style="clear:both" class="field">
<div class="field">
  <label for="structure">Structure:</label>
  <select name="structure" id="structure">
    <option value="General"{% ifequal link.structure 'General' %} selected="selected"{% endifequal %}>General</option>
    <option value="Categorized"{% ifequal link.structure 'Categorized' %} selected="selected"{% endifequal %}>Categorized</option>
  </select>
</div>

<div style="clear:both" class="field">
<label for="description">Descriptions:</label>
<textarea name="description" rows="5" cols="45" id="description">{{linkcategory.description}}</textarea>
</div>
<br class="clear" />
<div class="field">
  <label for="timees">Imagen:</label>
  <div id="imgmuestra" class="inputimg"></div>
</div>
<div id="images">
{% for image in images %}
<div class="imgremovable" id="muestra"><span class="info">Muestra <a class="ax" href="#" onclick="deleteImage('{{image.key}}','muestra');return false;">del</a></span><img src="/image/{{image.key}}/80/80/cropped/" /></div>
{% endfor %}
</div>

<input type="submit" name="save" id="publish" value="Save" />
<input type="hidden" name="codenum" id="codenum" value="{{filekey}}" />
<br class="clear" />
</form>
{% endblock %}
